﻿@using CNKI.TPI.Web.Base
@using CNKI.TPI.Web.Search.BLL
@using CNKI.TPI.Web.Search.Model
<script>

    //删除
    function del(dbcode, sysid) {
        if ("@SessionHelper.HasDeleteRight(ViewBag.DbID)" == "False") {
            messageAlert("您没有删除权限！");
            return;
        }
        confirmDialog('确定要删除吗?', function () {
            var datapara = { "dbcode": dbcode, "sysid": sysid };
            $.ajax({
                type: "GET",
                url: timestamp("@Html.Raw(Url.Action("DelMetaData", "Submit"))"),
                data: datapara,
                success: function (m) {
                    if (m == "True") {
                        messageAlert("操作成功！");
                        //刷新
                        $('#pageIndexNow').val(1);
                        searchResult();
                    }
                    else {
                        messageAlert("操作失败！");
                    }
                },
                error: function (e)
                { }
            })
        })
    }
    //审核
    function view(code, id, checkstatus, errorinfo) {
        if ("@SessionHelper.HasCheckRight(ViewBag.DbID)" == "False") {
            messageAlert("您没有审核权限！");
            return;
        }
        $("#sysID").val(id);
        $("#dbCode").val(code);
        $("#note").val(errorinfo);
        $("#passStatus").val(checkstatus);
        if (checkstatus != 1) {
            disableinfo();
        }
        else {
            enableinfo();
        }
        showView();
    }
    function disableinfo() {
        $("#passResons").attr("disabled", "disabled");
        $("#note").attr("disabled", "disabled");
    }
    function enableinfo() {
        $("#passResons").removeAttr("disabled", "disabled");
        $("#note").removeAttr("disabled", "disabled");
    }
    function closeView() {
        $(".talkDivBg").hide();
        $(".review").hide();
    }
    function showView() {
        $(".talkDivBg").show();
        $(".review").show();
    }
    function selectchange() {
        if ($("#passStatus").val() != 1) {
            disableinfo();
        }
        else {
            enableinfo();
        }
    }
    //保存
    function saveInfo() {
        var errorinfo = $("#note").val();
        var status = $("#passStatus").val();
        //var resons = $("#passResons").val();

        var sysid = $("#sysID").val();
        var dbCode = $("#dbCode").val();
        if (status == 2) {
            resons = "";
            errorinfo = "";
        }

        $.ajax({
            type: "POST",
            url: "@Html.Raw(Url.Action("UpdateMetaData", "Submit"))?dbCode=" + dbCode + "&status=" + status + "&errorinfo=" + errorinfo + "&sysid=" + sysid,
            success: function (m) {
                if (m == "True") {
                    messageAlert("操作成功！");
                    closeView();
                    //刷新
                    $('#pageIndexNow').val(1);
                    searchResult();
                }
                else {
                    messageAlert("操作失败！");
                }
            },
            error: function (e)
            { }
        })
    }

    function editInfo(e, thisid) {
        if ("@SessionHelper.HasModifyRight(ViewBag.DbID)" == "False") {
            messageAlert("您没有修改权限！");
            return;
        }
        var sysid = $("#sysID").val();//弹窗点击修改
        var dbCode = $("#dbCode").val();
        var displayname = escape($("#displayName").val());
        if (thisid != "") //列表点击修改
        {
            sysid = thisid;
        }
        var url = "@Html.Raw(Url.Action("index", "SubmitOnline"))" + "?dbCode=" + dbCode + "&displayDBName=" + displayname + "&sysid=" + sysid;
        var w = window.open();
        w.location = timestamp(url);
    }
    function reasonchange() {
        if ($("#passResons").find("option:selected").val() != "") {
            $("#note").val($("#passResons").find("option:selected").text());
        }
        else {
            $("#note").val("");
        }
    }

    //全选
    function checkall(e) {
        if ($(e).attr("checked") == "checked") {
            $(".checkboxlist input[type='checkbox']").each(function () {
                $(this).attr("checked", "checked");
            })
        }
        else {
            $(".checkboxlist input[type='checkbox']").each(function () {
                $(this).removeAttr("checked", "checked");
            })
        }
    }
    $(".checkboxlist input[type='checkbox']").click(function () {
        //循环判断列表中的checkbox，如果全部选中则全选框呈勾选状态
        var m = 0;
        if ($(this).attr("checked") != "checked") {
            $("input.listheader").removeAttr("checked", "checked");
        }
        else {
            $(".checkboxlist input[type='checkbox']").each(function () {
                if ($(this).attr("checked") != "checked") {
                    m = 1;
                }
            })
            if (m == 1) {
                $("input.listheader").removeAttr("checked", "checked");
            }
            else {
                $("input.listheader").attr("checked", "checked");
            }
        }

    })
    //批量审核
    function bathView() {
        if ("@SessionHelper.HasCheckRight(ViewBag.DbID)" == "False") {
            messageAlert("您没有审核权限！");
            return;
        }
        var ckbs = $(".checkboxlist input[type='checkbox']:checked");
        if (ckbs.size() == 0) {
            messageAlert("请选择要审核的记录！");
            return;
        }
        confirmDialog('确定要审核吗?', function () {
            var checkedstr = [];
            ckbs.each(function () {
                checkedstr.push($(this).val());
            })
            $.ajax({
                type: "POST",
                url: "@Html.Raw(Url.Action("UpdateMetaData", "Submit"))?dbCode=" + $("#dbCode").val() + "&status=2" + "&errorinfo=''" + "&sysid=" + checkedstr.toString(),
                success: function (m) {
                    if (m == "True") {
                        messageAlert("操作成功！");
                        $('#pageIndexNow').val(1);
                        searchResult();
                    }
                    else {
                        messageAlert("操作失败！");
                    }
                },
                error: function (e)
                { }
            })
        })
    }
    $(function () {
        var ckbs = $(".checkboxlist input[type='checkbox']");
        if (ckbs.size() == 0) {
            $(".listheader").hide();
        }
        else {
            $(".listheader").show();
        }
    })
</script>
<div class="order-box clearfix">

    @*排序*@
    <div class="fl">

        <a class="btn btn-submit btn-warn-f" style="padding-left: 10px; padding-right: 10px" onclick="bathView()">批量审核</a>

        <span class='taxis'>排序：
            @if (ViewBag.SortField != null)
            {
                foreach (var item in ViewBag.SortField)
                {
                    if (@ViewBag.SortFiledNow == @item.FieldName)
                    {
                <a href="javascript:void(0);" class='cur'  onclick="sortClick('@ViewBag.SortDescAsc','@item.FieldName')">@item.FieldDispName
                    @if (@ViewBag.SortDescAsc == "desc")
                    {<i class="iconfontdesc"></i>}
                    else
                    {<i class="iconfontasc"></i>}
                </a>
                    }
                    else
                    {
                <a href="javascript:void(0);" onclick="sortClick('@ViewBag.SortDescAsc','@item.FieldName')">@item.FieldDispName</a>
                    }

                }
            }
        </span>
    </div>
    @*显示模式及分页汇总*@
    <div class="fr order-r">

        @{if (@ViewBag.TotalPage == 0)
          {
            <span>0 条结果 0 /0</span>
          }
          else
          {
            <span>@ViewBag.ResultCount 条结果 @ViewBag.PageNow /@ViewBag.TotalPage</span>
          }
        }
        @if (ViewBag.TotalPage > 0 && ViewBag.PageNow != ViewBag.TotalPage)
        {
            int nextpage = ViewBag.PageNow + 1;
            <a href="javascript:void(0);" class="next-t" onclick="searchPageNew('@nextpage')" ></a>
        }
        else
        {
            <a href="javascript:return false;"  onclick="return false" class="next-t disable"></a>
        }

    </div>
</div>
@* “全文下载”弹层 *@
<div class="talkDiv Down" style="display: none; top: 250px">
    <div class="talkDiv-title" style="line-height: 40px; padding-left: 10px; font-size: 16px; border-bottom: 1px solid #DADADA; background-color: #efefef; font-family: 微软雅黑">
        <span>下载</span>
        <a class="icon icon-close" title="关闭" href="javascript:void(0);" onclick="closedown()" style="top: 15px"><i class="iconfont icon-error3"></i></a>
    </div>
    <div class="talkDiv-body" style="padding-top: 25px">
        <ul class="video-download">
        </ul>
    </div>
</div>
<!--talkDiv弹出层(不带图片，宽550)-->

<div class="talkDiv talkW-800 form-h form-h-8em review" style="margin-top: -135px; display: none">
    <div class="talkDiv-title">
        <a class="icon icon-close" title="关闭" href="javascript:void(0);" onclick="closeView()" style="top: 15px"><i class="iconfont icon-error3"></i></a>
    </div>
    <div class="talkDiv-body talkDiv-body1" style="padding: 15px 40px 20px 20px">
        <h2 class='bbsolid'><i class="blue-block"></i><span>审核情况</span></h2>
        <div class="exam-detail">
            <div class="f-gp">
                <div class="f-lb">
                    <label class="f-label">通过状态：</label>
                </div>
                <div class="f-ct">
                    <select class="f-select span3" id="passStatus" onchange="selectchange()">
                        <option value="2">合格</option>
                        <option selected="selected" value="1">不合格</option>
                    </select>
                    <select class="f-select span3" id="passResons" onchange="reasonchange()">
                        <option value="">请选择</option>
                        @{if (ViewBag.ErrorInfo != null)
                          {
                              foreach (SYS_CMS_ERRORINFOCONFIG item in ViewBag.ErrorInfo)
                              {          
                            <option value="@item.SysID">@item.ErrorInfoList</option>
                              }
                          }
                        }
                        }
                    </select>
                </div>
            </div>
        </div>
        <div class="f-gp" style="margin-top: 10px">
            <div class="f-lb">
                <label class="f-label">描述：</label>
            </div>
            <div class="f-ct">
                <textarea rows="8" class="f-textarea span6" id="note" style="width: 425px"></textarea>
            </div>
        </div>
        <div class="f-gp">
            <div class="f-lb"></div>
            <div class="f-ct" style="margin-left: 182px">
                <a class="btn btn-m btn-prim-f" href="javascript:void(0);" onclick="saveInfo('')">确定</a>
                <a class="btn btn-m" href="javascript:void(0);" onclick="editInfo(this,'')">修改细缆</a>
            </div>
        </div>

    </div>
</div>
<input type="hidden" id="sysID" name="sysID" />
<input type="hidden" id="dbCode" name="dbCode" value="@ViewBag.DbName"/>
<input type="hidden" id="displayName" name="displayName" value="@ViewBag.DisplayName" />

<table width="100%" cellspacing="0" cellpadding="0" border="0" class="table table-grey" id="table_list">
    <thead>
        <tr class="thead">
            <th class="tdnum">
                <input type="checkbox" class="listheader" onclick="checkall(this)"></th>
            @{ System.Data.DataRow columnInfo = null;
               System.Data.DataRow[] columnInfoList = null;
               foreach (System.Data.DataColumn item in ViewBag.SearchResult.Columns)
               {
                   columnInfoList = ViewBag.ResultColumnInfo.Select(string.Format("Name='{0}'", item.ColumnName));
                   if (columnInfoList.Length > 0)
                   {
                       columnInfo = columnInfoList[0];
                       if (!item.ColumnName.StartsWith("SYS_FLD_") && @columnInfo["Name"].ToString() != ColumnAliasHelper.GetColumn(@ViewBag.DbName, "摘要")
                           && @columnInfo["Name"].ToString() != ColumnAliasHelper.GetColumn(@ViewBag.DbName, "浏览量")
                           && @columnInfo["Name"].ToString() != ColumnAliasHelper.GetColumn(@ViewBag.DbName, "SYS_FLD_DOWNLOADRATE"))
                       {
                <th width="@columnInfo["Width"]%">@columnInfo["DispName"]</th>
                       }
                   }
               }
            }
            <th>审核标志</th>
            <th>审核</th>
            <th>修改</th>
            <th>删除</th>
            <th>下载</th>
        </tr>
    </thead>
    <tbody>

        @{int sortno = ViewBag.PageSize * (ViewBag.PageNow - 1) + 1;
          foreach (System.Data.DataRow dr in ViewBag.SearchResult.Rows)
          {
              int j = 0;
            <tr>
                <td style="word-break: normal;width:60px" class="checkboxlist">

                    @if (dr["SYS_FLD_CHECKSTATE"].ToString() != "2")
                    {
                        <input name="" type="checkbox" value="@dr["SYS_FLD_SYSID"]" />
                    }
                    @sortno
                </td>
                @foreach (System.Data.DataColumn column in ViewBag.SearchResult.Columns)
                {
                    if (j == 0)//第一列加链接
                    {
                        int browsetype = (int)BrowseFromType.AuditBrowse;
                        string str = ColumnAliasHelper.GetContent(dr, ViewBag.DbName, column.ColumnName);
                    <td><a target="_blank"  href="~/Detail?dbID=@ViewBag.DbID&dbName=@ViewBag.DbName&type=@ViewBag.MediaType&sysID=@dr["SYS_FLD_SYSID"]&Browse=@browsetype">
                        @Html.Raw(ColumnAliasHelper.SubContent(str, ConfigHelper.GetSearchResultCutLengh()))
                    </a></td>
                    }
                    else
                    {
                        if (column.ColumnName.StartsWith("SYS_FLD_") || column.ColumnName == "__sys_from"
                            || column.ColumnName == ColumnAliasHelper.GetColumn(@ViewBag.DbName, "摘要")
                            || column.ColumnName == ColumnAliasHelper.GetColumn(@ViewBag.DbName, "浏览量"))
                        {
                            //<td style="display: none"></td>
                        }
                        else
                        {

                            if (column.ColumnName == ColumnAliasHelper.GetColumn(@ViewBag.DbName, "发表时间"))
                            { 
                    <td style="width: 100px; text-align: center">@Html.Raw(ColumnAliasHelper.GetContent(dr, ViewBag.DbName, column.ColumnName))</td>
                            }
                            else
                            {                                
                    <td>@Html.Raw(ColumnAliasHelper.GetContent(dr, ViewBag.DbName, column.ColumnName))</td>
                            }

                        }
                    }
                    j++;

                }
                <td class="tc">
                    @{
                string status = "";
                string markstate = "";
                if (!String.IsNullOrEmpty(dr["SYS_FLD_CHECKSTATE"].ToString()))
                {
                    markstate = dr["SYS_FLD_CHECKSTATE"].ToString();
                }
                if (markstate == "0")
                {
                    status = "待审核";
                }
                else if (markstate == "1")
                {
                    status = "未通过审核";
                }
                else if (markstate == "2")
                {
                    status = "通过审核";
                }
                    }
                    @Html.Raw(status)
                </td>
                <td class="tc">
                    @{
                        <a href="javascript:void(0)" onclick="view('@ViewBag.DbName','@dr["SYS_FLD_SYSID"].ToString()','@dr["SYS_FLD_CHECKSTATE"].ToString()','@dr["SYS_FLD_ERRORINFO"].ToString()')" >审核</a>
                    }
                </td>
                <td class="tc">
                    @{
                        <a  href="javascript:void(0)" onclick="editInfo(this,@dr["SYS_FLD_SYSID"])">修改</a>@*
                        <a target="_blank" href="~/SubmitOnline/index?dbCode=@ViewBag.DbName&displayDBName=@Server.UrlEncode(ViewBag.DisplayName)&sysid=@dr["SYS_FLD_SYSID"]">修改</a>*@
                    }
                </td>
                <td class="tc">
                    @{
                        <a href="javascript:void(0)" onclick="del('@ViewBag.DbName','@dr["SYS_FLD_SYSID"].ToString()')" >删除</a>
                    }
                </td>
                <td class="tc">
                    @{
                int type = (int)MediaType.Doc;
                int downtype = (int)DownFromType.AuditDown;
                <a href="javascript:void(0)" onclick="downfilelist('@ViewBag.dbId','@dr["SYS_FLD_SYSID"].ToString()','@ViewBag.DbName','@type','@Html.Raw(Url.Action("IsShowDown", "File"))','@Html.Raw(Url.Action("GetFilesByRecordID", "SingleSearch"))','@downtype')" class='iconfont icon-xiajiantou2'></a>
                    }
                </td>
            </tr>
                sortno = sortno + 1;
          }
         
        }
    </tbody>
</table>

@*//分页*@
<div class="pagenav pagenav-02">
    @*上一页*@
    @if (ViewBag.TotalPage > 0)
    {
        if (ViewBag.PageNow != 1)
        {
            int thispage = ViewBag.PageNow - 1;
        <a href="javascript:void(0);" class="page-prev" onclick="searchPageNew('@thispage')" >上一页</a>
        }

        else
        {
        <a href="javascript:return false;"  onclick="return false" class="page-prev disable">上一页</a>
        }
  
@*循环初始化页码*@
        foreach (string numpage in ViewBag.PageList)
        {
            if (numpage != "0")
            {
                int m = int.Parse(numpage);
                if (m == ViewBag.PageNow)
                {
        <a href="javascript:void(0);" class="active" onclick="searchPageNew('@numpage')">@numpage</a>
                    
                }
                else
                {
        <a href="javascript:void(0);" onclick="searchPageNew('@numpage')">@numpage</a>
                }

            }
            else
            {
        <i class="iconfont icon-dian2"></i>
            }

        }
@*下一页*@
   
        if (ViewBag.PageNow != ViewBag.TotalPage)
        {
            int nextpage = ViewBag.PageNow + 1;
        <a href="javascript:void(0);" class="page-next" onclick="searchPageNew('@nextpage')" >下一页</a>
        }

        else
        {
        <a href="javascript:return false;"  onclick="return false" class="page-prev disable">下一页</a>
        }
    }
    else
    {
        <label>暂无数据！</label>
        
    }

</div>




